﻿<Window x:Class="ErikEJ.SqlCeToolbox.Dialogs.TableBuilderDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:self="clr-namespace:ErikEJ.SqlCeToolbox"
        xmlns:Dialogs="clr-namespace:ErikEJ.SqlCeToolbox.Dialogs"
        Icon="../Resources/propes.PNG"
        Title="Build Table" 
        WindowStyle="SingleBorderWindow"
        WindowStartupLocation="CenterOwner"
        ResizeMode="CanResize" 
        ShowInTaskbar="False"
        mc:Ignorable="d" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        d:DesignHeight="430" 
        d:DesignWidth="573" Loaded="Window_Loaded" MinHeight="300" MinWidth="620" Width="781" Height="411">
       <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="0" />
            <RowDefinition Height="0*" />
            <RowDefinition Height="194*" />
        </Grid.RowDefinitions>
        <Label Name="lblTable" Margin="12,12,0,0" Grid.Row="2" Height="28" VerticalAlignment="Top" HorizontalAlignment="Left" Width="143" Content="Name"></Label>
        
        <TextBox Name="txtTableDesc" Margin="100,14,12,0" MaxWidth="300" MinWidth="300" HorizontalAlignment="Left" Grid.Row="2" Height="23" VerticalAlignment="Top" />
        <!--<StackPanel Margin="0,0,2,3" Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="2"></StackPanel>-->
        <Button Name="SaveButton" IsDefault="True"  Click="SaveButton_Click" Grid.Row="2" Margin="0,0,93,12" HorizontalAlignment="Right" Width="75" Height="23" VerticalAlignment="Bottom">Script!</Button>
        <Button Name="CancelButton" IsCancel="True"  Click="CancelButton_Click" Grid.Row="2" Margin="0,0,12,12" HorizontalAlignment="Right" Width="75" Height="23" VerticalAlignment="Bottom">Cancel</Button>
        <Button Name="AddButton" Click="AddButton_Click" Grid.Row="2" Margin="12,0,12,12" HorizontalAlignment="Left" Width="75" Height="23" VerticalAlignment="Bottom">Add</Button>
        <Button Name="DeleteButton" Click="DeleteButton_Click" Grid.Row="2" Margin="96,0,12,12" HorizontalAlignment="Left" Width="75" Height="23" VerticalAlignment="Bottom">Delete</Button>
        <DataGrid 
            AutoGenerateColumns="False" 
            CanUserDeleteRows="True" 
            CanUserAddRows="True" 
            Grid.Row="2" 
            Margin="12,46,12,41" 
            Name="dgridCols"  
            SelectionMode="Single" 
            SelectionUnit="FullRow"
            PreparingCellForEdit="PreparingCellForEdit"
            >
            <DataGrid.Columns>
                <DataGridTextColumn MinWidth="100" x:Name="colName" Header="Name" Width="Auto" Binding="{Binding Name, Mode=TwoWay}" />
                <DataGridComboBoxColumn
                    MinWidth="100"
                    Header="Data Type"
                    x:Name="colDataType"                    
                    SelectedValueBinding="{Binding DataType, UpdateSourceTrigger=PropertyChanged}"
                    SelectedValuePath="Key"
                    DisplayMemberPath="Value.Name"
                    >
                    <DataGridComboBoxColumn.EditingElementStyle>
                        <Style TargetType="{x:Type ComboBox}">
                            <EventSetter Event="SelectionChanged" Handler="DataTypeFieldChanged" />
                        </Style>
                    </DataGridComboBoxColumn.EditingElementStyle>
                </DataGridComboBoxColumn>
                <DataGridTextColumn MinWidth="75" x:Name="colLength" Header="Length" Width="Auto" Binding="{Binding Length, Mode=TwoWay}" />
                <DataGridCheckBoxColumn  MinWidth="75" x:Name="colNull" Header="Allow Null" Width="Auto" Binding="{Binding AllowNull, Mode=TwoWay}" />
                <DataGridCheckBoxColumn  MinWidth="75" x:Name="colPrimary" Header="Primary Key" Width="Auto" Binding="{Binding PrimaryKey, Mode=TwoWay}" />
                <DataGridTextColumn MinWidth="100" x:Name="colDefault" Header="Default" Width="Auto" Binding="{Binding DefaultValue, Mode=TwoWay}" />
                <DataGridCheckBoxColumn MinWidth="75" x:Name="colIdentity" Header="Identity" Width="Auto" Binding="{Binding Identity, Mode=TwoWay}" />
                <DataGridTextColumn MinWidth="60" x:Name="colPrecision" Header="Precision" Width="Auto" Binding="{Binding Precision, Mode=TwoWay}" />
                <DataGridTextColumn MinWidth="60" x:Name="colScale" Header="Scale" Width="Auto" Binding="{Binding Scale, Mode=TwoWay}" />
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</Window>
